<?php
require_once("Accountant.class.php");
require_once("exceptions/AppExceptions.class.php");

class SpecialFileStateAccountant extends Accountant {

	private $certificationNumber = array();

	private $certificationCodification = array();
	
	private $sequenceNumber = array();
	 
	private $manufactory = array();
	
	private $authenticationMark = array();
	
	private $steelNumber =  array();
	
	private $size1 = array();
	
	private $size2 = array();
	
	private $size3 = array();
	
	private $count = array();
	
	private $unitWeight = array();
	
	private $weight = array();
	
	private $orderNumber = array();
	
	private $orderSubitemNumber = array();
	
	private $unitPrice = array();
	
	private $materialNumber = array();
	
	private $consignmentBatch = array();
	
	private $sampleBatch = array();
	
	private $facheNumber = array();
	
	private $purchaseNumber = array();
	
	private $shipmentDate = array();
	
	private $month = array();
	
	private $vehicleNumber = array();
	
	private $consignee = array();
	
	private $remark = array();

	private $stat = array();
	/**
	 * 构造函数，根据文件名称初始化sql语句。
	 *
	 * @param string $filename
	 */
	public function __construct($filename){
		$this->sql = "select *,sum(count) as sumCount from little_main where filename = '$filename' 
					group by sampleBatch,orderNumber,orderSubitemNumber
					order by certificationNumber, size1, size2, size3;";
	}


	/**
	 * 执行查询命令，并整理查询的结果
	 *
	 */
	public function execute(){
		$this->result = DB::query($this->sql);
		if($this->result == false){
			return;
		}
		while($row = $this->result->fetch_assoc()){
			array_push($this->certificationNumber, $row['certificationNumber']);
			array_push($this->certificationCodification, $row['certificationCodification']);
			array_push($this->sequenceNumber, $row['sequenceNumber']);
			array_push($this->manufactory, $row['manufactory']);
			array_push($this->authenticationMark, $row['authenticationMark']);
			array_push($this->steelNumber, $row['steelNumber']);	
			array_push($this->size1, $row['size1']);
			array_push($this->size2, $row['size2']);
			array_push($this->size3, $row['size3']);
			array_push($this->count, $row['sumCount']);
			array_push($this->unitWeight, $row['unitWeight']);
			array_push($this->weight, $row['sumCount']*$row['unitWeight']);
			array_push($this->orderNumber, $row['orderNumber']);
			array_push($this->orderSubitemNumber, $row['orderSubitemNumber']);
			array_push($this->unitPrice,$row['unitPrice']);
			array_push($this->materialNumber, $row['materialNumber']);
			array_push($this->consignmentBatch, $row['consignmentBatch']);
			array_push($this->sampleBatch,$row['sampleBatch']);
			array_push($this->facheNumber,$row['facheNumber']);
			array_push($this->purchaseNumber,$row['purchaseNumber']);
			array_push($this->shipmentDate,$row['shipmentDate']);
			array_push($this->month,$row['month']);
			array_push($this->vehicleNumber, $row['vehicleNumber']);
			array_push($this->consignee, $row['consignee']);
			array_push($this->remark, $row['remark']);
			if(!empty($row['certificationNumber']) && isset($row['certificationNumber'])){
				$query_chuku = "select certificationNumber from little_chuku where certificationNumber = '{$row['certificationNumber']}'";
				DB::query($query_chuku);
				$row_chuku = DB::getResult()->fetch_assoc();
				if(count($row_chuku['certificationNumber'])>0){
					array_push($this->stat, '出库');
				}else{
					$query_ruku = "select certificationNumber from little_ruku 
					where certificationNumber = '{$row['certificationNumber']}'";
					DB::query($query_ruku);
					$row_ruku = DB::getResult()->fetch_assoc();
					if(count($row_ruku['certificationNumber'])>0){
						array_push($this->stat,'库中');
					}else{
						array_push($this->stat,'未动');
					}
				}
			}else 
				array_push($this->stat,'');
		}
	}
	/**
	 * @return unknown
	 */
	public function getAuthenticationMark() {
		return $this->authenticationMark;
	}
	
	/**
	 * @return unknown
	 */
	public function getCertificationCodification() {
		return $this->certificationCodification;
	}
	
	/**
	 * @return unknown
	 */
	public function getCertificationNumber() {
		return $this->certificationNumber;
	}
	
	/**
	 * @return unknown
	 */
	public function getFacheNumber() {
		return $this->facheNumber;
	}
	
	/**
	 * @return unknown
	 */
	public function getConsignee() {
		return $this->consignee;
	}
	
	/**
	 * @return unknown
	 */
	public function getConsignmentBatch() {
		return $this->consignmentBatch;
	}
	
	/**
	 * @return unknown
	 */
	public function getCount() {
		return $this->count;
	}
	
	/**
	 * @return the $weight
	 */
	public function getWeight() {
		return $this->weight;
	}
	
	/**
	 * @return int
	 */
	public function getFileId() {
		return $this->fileId;
	}
	
	/**
	 * @return unknown
	 */
	public function getHaveMc() {
		return $this->haveMc;
	}
	
	/**
	 * @return unknown
	 */
	public function getManufactory() {
		return $this->manufactory;
	}
	
	/**
	 * @return unknown
	 */
	public function getMaterialNumber() {
		return $this->materialNumber;
	}
	
	/**
	 * @return unknown
	 */
	public function getMonth() {
		return $this->month;
	}
	
	/**
	 * @return unknown
	 */
	public function getOrderNumber() {
		return $this->orderNumber;
	}
	
	/**
	 * @return unknown
	 */
	public function getOrderSubitemNumber() {
		return $this->orderSubitemNumber;
	}
	
	/**
	 * @return unknown
	 */
	public function getPurchaseNumber() {
		return $this->purchaseNumber;
	}
	
	/**
	 * @return unknown
	 */
	public function getRemark() {
		return $this->remark;
	}
	
	/**
	 * @return unknown
	 */
	public function getSampleBatch() {
		return $this->sampleBatch;
	}
	
	/**
	 * @return unknown
	 */
	public function getSequenceNumber() {
		return $this->sequenceNumber;
	}
	
	/**
	 * @return unknown
	 */
	public function getShipmentDate() {
		return $this->shipmentDate;
	}
	
	/**
	 * @return unknown
	 */
	public function getSize1() {
		return $this->size1;
	}
	
	/**
	 * @return unknown
	 */
	public function getSize2() {
		return $this->size2;
	}
	
	/**
	 * @return unknown
	 */
	public function getSize3() {
		return $this->size3;
	}
	
	/**
	 * @return unknown
	 */
	public function getSteelNumber() {
		return $this->steelNumber;
	}
	
	/**
	 * @return unknown
	 */
	public function getUnitPrice() {
		return $this->unitPrice;
	}
	
	/**
	 * @return unknown
	 */
	public function getUnitWeight() {
		return $this->unitWeight;
	}
	
	/**
	 * @return unknown
	 */
	public function getVehicleNumber() {
		return $this->vehicleNumber;
	}
	
	public function getStat(){
		return $this->stat;
	}
}
?>